package ex.com.jm.food.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Email;
/**
 * 用户实体层
 * @author zhaojw
 *
 */
@Entity
@Table(name="jm_user")
public class User implements Serializable {


	private static final long serialVersionUID = 1L;
	@Id
	@GenericGenerator(name="user_id",strategy="uuid")
	@GeneratedValue(generator="user_id")
	@Column(name="user_id",nullable=false,unique=true,length=128)
	private String userId;//用户主键
	@Column(name="user_name",nullable=false,unique=true,length=32)
	private String userName;//用户名昵称
	@Column(name="real_name",nullable=false,length=32)
	private String realName;//用户真实姓名
	@Column(name="user_email",nullable=false,unique=true,length=32)
	@Email(message="邮箱格式非法")
    private String userEmail;//用户注册邮箱，登录帐号
	@Column(name="user_pwd",nullable=false,length=128)
    private String userPwd;//用户登录密码
	@Column(name="user_phone",nullable=false,unique=true,length=32)
    private String userPhone;//用户联系电话
	@Column(name="user_address",nullable=false,length=32)
    private String userAddress;//用户地址
	@Column(name="gender",nullable=false,length=1)
    private int gender;//用户性别;1:男，0:女
	@Column(name="type",nullable=false,length=1)
    private int type;//区分普通用户和会员；1：会员，0:普通用户
	@Column(name="user_points",nullable=false,length=11)
	private int userPoints;//用户积分，当达到一定程度后，可申请成为会员
	@Column(name="status",nullable=false,length=1)
	private int status;//用户选择是否申请成为会员，1:申请0：不申请（默认）
	@Column(name="user_image",length=32)
	private String userImage;//用户头像
	@Column(name="created",nullable=false,length=32)
    private String created;//用户帐号创建时间
	@Column(name="create_id",nullable=true,length=128)
    private String createId;//用户创建的管理员id
	@OneToMany(mappedBy="userId",fetch=FetchType.EAGER)
	@Cascade({CascadeType.SAVE_UPDATE,CascadeType.DELETE})
	private Set<Evaluation> evals=new HashSet<Evaluation>();
	@OneToMany(mappedBy="userId",fetch=FetchType.EAGER)
	@Cascade({CascadeType.SAVE_UPDATE,CascadeType.DELETE})
	private Set<Comment> cments=new HashSet<Comment>();
	@OneToMany(mappedBy="userId",fetch=FetchType.EAGER)
	@Cascade({CascadeType.SAVE_UPDATE,CascadeType.DELETE})
	private Set<Order> orders=new HashSet<Order>();
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getRealName() {
		return realName;
	}
	public void setRealName(String realName) {
		this.realName = realName;
	}
	public String getUserEmail() {
		return userEmail;
	}
	public void setUserEmail(String userEmail) {
		this.userEmail = userEmail;
	}
	public String getUserPwd() {
		return userPwd;
	}
	public void setUserPwd(String userPwd) {
		this.userPwd = userPwd;
	}
	public String getUserPhone() {
		return userPhone;
	}
	public void setUserPhone(String userPhone) {
		this.userPhone = userPhone;
	}
	public String getUserAddress() {
		return userAddress;
	}
	public void setUserAddress(String userAddress) {
		this.userAddress = userAddress;
	}
	public int getGender() {
		return gender;
	}
	public void setGender(int gender) {
		this.gender = gender;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public String getCreated() {
		return created;
	}
	public void setCreated(String created) {
		this.created = created;
	}
	public String getCreateId() {
		return createId;
	}
	public void setCreateId(String createId) {
		this.createId = createId;
	}
	public Set<Evaluation> getEvals() {
		return evals;
	}
	public void setEvals(Set<Evaluation> evals) {
		this.evals = evals;
	}
	public Set<Comment> getCments() {
		return cments;
	}
	public void setCments(Set<Comment> cments) {
		this.cments = cments;
	}
	public int getUserPoints() {
		return userPoints;
	}
	public void setUserPoints(int userPoints) {
		this.userPoints = userPoints;
	}
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}
	public String getUserImage() {
		return userImage;
	}
	public void setUserImage(String userImage) {
		this.userImage = userImage;
	}
	public Set<Order> getOrders() {
		return orders;
	}
	public void setOrders(Set<Order> orders) {
		this.orders = orders;
	}
}
